﻿using System;
namespace Kis.Xroad.Eu {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ComplexWithSoapEncBase64", Namespace="http://kis.x-road.eu/", Target=typeof(ComplexWithSoapEncBase64))]
    public class ComplexWithSoapEncBase64Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ComplexWithSoapEncBase64 clazz;
        
        public ComplexWithSoapEncBase64Serializer(ComplexWithSoapEncBase64 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXmlAttributes(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXmlAttributes(Writer);
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Sisu");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBase64Binary(((byte[])(clazz.Sisu))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("Sisu2");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBase64Binary(((byte[])(clazz.Sisu2))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXmlAttributes(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXmlAttributes(Reader);
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Sisu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ComplexWithSoapEncBase64>Sisu");
                }
                clazz.Sisu = new global::Xtee.Core.Schema.XsdBase64Binary(Reader.ReadElementString("Sisu")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ComplexWithSoapEncBase64>Sisu", Reader.LocalName);
            }
            if (Reader.LocalName=="Sisu2") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ComplexWithSoapEncBase64>Sisu2");
                }
                clazz.Sisu2 = new global::Xtee.Core.Schema.XsdBase64Binary(Reader.ReadElementString("Sisu2")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ComplexWithSoapEncBase64>Sisu2", Reader.LocalName);
            }
        }
    }
}
